package com.jcfy.project.module.client;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jcfy.framework.base.ClientBaseController;
import com.jcfy.framework.web.domain.AjaxResult;
import com.jcfy.framework.web.page.TableDataInfo;
import com.jcfy.project.module.domain.TCategory;
import com.jcfy.project.module.service.ITCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 类目Controller
 *
 * @author hushuai
 * @date 2020-08-16
 */
@Api("分类信息")
@RestController
@RequestMapping("/client/category")
public class CategoryController extends ClientBaseController {

    @Autowired
    private ITCategoryService tCategoryService;

    /**
     * 查询类目首页
     */
    @ApiOperation("分类信息-首页")
    @PostMapping("/home" )
    public TableDataInfo home(TCategory tCategory) {
        startPage();
        List<TCategory> list = tCategoryService.selectTCategoryList(tCategory);
        return getDataTable(list);
    }

    /**
     * 查询类目列表
     */
    @PostMapping("/list" )
    public AjaxResult list() {
        TCategory tCategory = new TCategory();
        tCategory.setStatus(0);
        PageHelper.startPage(1, 100).setOrderBy("sort ASC");
        List<TCategory> list = tCategoryService.selectTCategoryList(tCategory);
        PageInfo<TCategory> pageInfo = new PageInfo<TCategory>(list);
        return AjaxResult.success(pageInfo);
    }

}
